﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using DataObjects.Interfaces;
using DataObjects.Enums;

namespace DataObjects.ShipSystems
{
    public class Weapon : ShipSystem, IWeapon, ICloneable
    {
        private WeaponType weaponType;
        private double baseCooldown;
        private double cooldown;
        private int size;
        private float baseDmg;

        #region IWeapon Members
        public WeaponType WeaponType
        {
            get { return weaponType; }
            set { weaponType = value; }
        }

        public double BaseCooldown
        {
            get { return baseCooldown; }
            set { baseCooldown = value; }
        }

        public double Cooldown
        {
            get { return cooldown; }
            set { cooldown = value; }
        }

        public bool CanFire
        {
            get
            {
                if (cooldown > 0d)
                {
                    cooldown -= GlobalData.Delta;
                    if (cooldown < 0d)
                    {
                        cooldown = 0d;
                        return true;
                    }

                    return false;
                }

                return true;
            }
        }

        public int WeaponSize
        {
            get { return size; }
            set { size = value; }
        }

        public float BaseDamage
        {
            get { return baseDmg; }
            set { baseDmg = value; }
        }

        public void Fired()
        {
            cooldown = baseCooldown;
        }
        #endregion

        #region ICloneable Members
        override public object Clone()
        {
            return this.MemberwiseClone();
        }
        #endregion
    }
}
